#include<stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main()
{
  pid_t id=fork();
  if(id==0)
  {
    //child
    int count=10;
    while(count--)
    {
      printf("I am child\n");
      sleep(1);
    }
  }

  else 
  {
    int status=0;
    //father
    pid_t ret=waitpid(id,&status,0);
    if(ret>=0)
    {
      printf("wait success\n");
      if(WIFEXITED(status))
      {
        printf("%d\n",WEXITSTATUS(status));
      }

      else 
      {
        printf("child not exit normal\n");
      }
    }
  }

  return 0;
}

